<?php
	class ViewHelper
	{
		var $ControllerName;
		var $ActionName;
		var $Model;
		
		function __construct($controllerName, $actionName, $model)
		{
			$this->ControllerName = $controllerName;
			$this->ActionName = $actionName;
			$this->Model = $model;
		}
		
		function GetBaseUrl()
		{
			return BASE_URL;
		}
		
		function BaseUrl()
		{
			print GetBaseUrl();
		}
		
		function ActionLink($c, $a, $t)
	    {
	        print $this->GetActionLink($c, $a, $t);
	    }
	    
	    function ActionUrl($c, $a)
	    {
	    	print $this->GetActionUrl($c, $a);
	    }
	    
	    function GetActionLink($c, $a, $t)
	    {
	        if ( strtolower($c) == strtolower($this->ControllerName) && 
	        	 strtolower($a) == strtolower($this->ActionName) )
	        {
	            return '<span>'.$t.'</span>';
	        }
	        else
	        {
				$url = $this->GetActionUrl($c, $a);
	            return '<a href="'.$url.'">'.$t.'</a>';
	        }
	    }
	    
	    function GetActionUrl($c, $a)
	    {
	    	if ( strtolower($a) == 'index' )
	    	{
	        	$url = BASE_URL.$c.'/';
	        	
	        	if (strtolower($c) == 'home')
	        		$url = BASE_URL;
	    	}
	        else
	            $url = BASE_URL.$c.'/'.$a;
	        
	        return $url;
	    }
	    
	    function GetModelValue($key)
	    {
	        if ( is_array($this->Model) ) {
	            if ( isset($this->Model[$key]) ) return $this->Model[$key];
	        }
	        
	        if ( is_object($this->Model[$key]) )
	        {
	            return $this->Model[$key]->$name;
	        }
	
	        return null;
	    }
	    
	    function ModelValue($name)
	    {
	        print GetModelValue($name);
	    }
	    
		
	}
?>